package com.xysoft.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class Action {
	private int id;
	private String code;
	private String name;
	private boolean leaf;
	private boolean front;
	private String keyButton;
	private String keyName;
	private int sort;
	private int level;
	private Set<UserAction> userActions;
	private Set<RoleAction> roleActions;
	private ActionColumn column;
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public boolean isLeaf() {
		return leaf;
	}
	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}
	public boolean isFront() {
		return front;
	}
	public void setFront(boolean front) {
		this.front = front;
	}
	@OneToMany(mappedBy="action", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
	public Set<UserAction> getUserActions() {
		return userActions;
	}
	public void setUserActions(Set<UserAction> userActions) {
		this.userActions = userActions;
	}
	@OneToMany(mappedBy="action", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
	public Set<RoleAction> getRoleActions() {
		return roleActions;
	}
	public void setRoleActions(Set<RoleAction> roleActions) {
		this.roleActions = roleActions;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "columnID")
	public ActionColumn getColumn() {
		return column;
	}
	public void setColumn(ActionColumn column) {
		this.column = column;
	}
	public String getKeyButton() {
		return keyButton;
	}
	public void setKeyButton(String keyButton) {
		this.keyButton = keyButton;
	}
	public String getKeyName() {
		return keyName;
	}
	public void setKeyName(String keyName) {
		this.keyName = keyName;
	}
	public int getSort() {
		return sort;
	}
	public void setSort(int sort) {
		this.sort = sort;
	}
	public int getLevel() {
		return level;
	}
	public void setLevel(int level) {
		this.level = level;
	}
}
